/*
 * 统一分页组件
 */
import React from "react";
import PropTypes from "prop-types";
import { Pagination } from "antd";

function showTotal(total) {
  return `总共 ${total} 条`;
}

const Index = props => (
  <div className="clear-both">
    <Pagination
      style={{ margin: 12, float: "right" }}
      showTotal={showTotal}
      {...props}
    />
  </div>
);

if (process.env.UMI_ENV !== "prod") {
  Index.propTypes = {
    onChange: PropTypes.func.isRequired,
    total: PropTypes.number.isRequired,
    current: PropTypes.number.isRequired,
    pageSize: PropTypes.number
  };
}

Index.defaultProps = {
  onChange: () => {},
  total: 0,
  current: 1,
  pageSize: 10
};

export default Index;
